﻿<?php 
require_once('../config.php');
if($_REQUEST['submitForm']=='TimePrayers'){
	$country = $_REQUEST['Country'];
	$sxml1 = simplexml_load_file('timePrayers.xml');
	foreach ($sxml1->countries->country as $sxml_country){
		foreach($sxml_country->cities->city as $sxml_city){
			if($country == $sxml_country->code."_".$sxml_city->name){
				$timeZone = $sxml_country->timeZone;
				$longitude =  $sxml_city->longitude;
				$latitude =  $sxml_city->latitude;
			}
		}
	}
	$method = $_REQUEST['Method'];
	$prayTime = new PrayTime($method);
	$date =  strtotime("now");
	$times = $prayTime->getPrayerTimes($date, $latitude, $longitude, $timeZone);
	echo json_encode($times);
}
?>